package edu.mse.camel.client.uml.collab.editor;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IPersistableElement;

import com.cea.papyrus.core.editor.ModelManager;
import com.cea.papyrus.diagraminterchange2.di2.Diagram;


/**
 * @author darpan
 *
 */
public class CollabEditorInput implements IEditorInput {

	private Diagram diagram;
	private ModelManager modelManager;
	private boolean source;
	private boolean target;
	
	public CollabEditorInput(Diagram diagram, ModelManager modelManager,
			boolean source) {
		this.diagram = diagram;
		this.modelManager = modelManager;
		if (source) {
			this.source = true;
			this.target = false;
		} else {
			this.source = false;
			this.target = true;
		}
	}
	
	@Override
	public boolean exists() {
		if (diagram != null) {
			return true;
		}
		return false;
	}
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((diagram == null) ? 0 : diagram.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		CollabEditorInput other = (CollabEditorInput) obj;
		if (diagram == null) {
			if (other.diagram != null)
				return false;
		} else if (!diagram.equals(other.diagram))
			return false;
		return true;
	}

	@Override
	public ImageDescriptor getImageDescriptor() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getName() {
		if (diagram != null) {
			return diagram.getName();
		}
		return null;
	}

	@Override
	public IPersistableElement getPersistable() {
		return null;
	}

	@Override
	public String getToolTipText() {
		return "UML Collaboration Editor";
	}

	@SuppressWarnings("unchecked")
	@Override
	public Object getAdapter(Class adapter) {
		// TODO Auto-generated method stub
		return null;
	}

	public ModelManager getModelManager() {
		return modelManager;
	}

	public Diagram getDiagram() {
		return diagram;
	}

	public boolean isSource() {
		return source;
	}

	public boolean isTarget() {
		return target;
	}

}
